using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace BouncinBall.Utility
{
    public class Velocity
    {
        Vector3 _vel;

        public Velocity()
        {
            _vel = new Vector3(0, 0, 0);
        }

        public Velocity(float magnitude, Vector3 direction)
        {
            direction.Normalize();
            _vel = direction * magnitude;
        }

        public Velocity(float dx, float dy, float dz)
        {
            _vel = new Vector3(dx, dy, dz);
        }

        public Vector3 UnitDirection
        {
            get
            {
                Vector3 tmp = new Vector3(_vel.X, _vel.Y, _vel.Z);
                tmp.Normalize();
                return tmp;
            }
        }

        public float Magnitude
        {
            get
            {
                return _vel.Length();
            }
        }

        public float Dx
        {
            get
            {
                return _vel.X;
            }
        }

        public float Dy
        {
            get
            {
                return _vel.Y;
            }
        }

        public float Dz
        {
            get
            {
                return _vel.Z;
            }
        }

        public Vector3 VelocityVector { get { return _vel; } }

        public void ApplyGravity(float magnitude, float elapsedSeconds)
        {
            _vel += new Vector3(0, 0, magnitude * elapsedSeconds);
        }

        public void ApplyAcceleration(Vector3 accel, float elapsedSeconds)
        {
        }

        // Declare which operator to overload (+), the operand types, and return type
        public static Velocity operator +(Velocity v1, Velocity v2)
        {
            return new Velocity(v1.Dx + v2.Dx, v1.Dy + v2.Dy, v1.Dz + v2.Dz);
        }
    }
}
